/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package business;

import java.math.BigDecimal;
import model.Account;
import model.AccountManager;

/**
 *
 * @author Administrator
 */
public class DrawCmd extends AbstractCommand{

    @Override
    public boolean execute(Object args) {
        assert(getAmount().compareTo(new BigDecimal(0)) > 0);
        Account account = AccountManager.getInstance().getAccountByID(getAccountID());
        if( account == null)
            return false;
        if( account.getPwd().equals(getPwd()) )        
            return account.draw(getAmount());
        else
            return false;
    }
    
    private BigDecimal amount;
    private String accountID;
    private String pwd;

    /**
     * @return the amount
     */
    public BigDecimal getAmount() {
        return amount;
    }

    /**
     * @param amount the amount to set
     */
    public void setAmount(BigDecimal amount) {
        this.amount = amount;
    }

    /**
     * @return the accountID
     */
    public String getAccountID() {
        return accountID;
    }

    /**
     * @param accountID the accountID to set
     */
    public void setAccountID(String accountID) {
        this.accountID = accountID;
    }

    /**
     * @return the pwd
     */
    public String getPwd() {
        return pwd;
    }

    /**
     * @param pwd the pwd to set
     */
    public void setPwd(String pwd) {
        this.pwd = pwd;
    }
}
